home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 51741 / 51741.xpi / chrome / content / core / jsStrings.js next >
Text File  |  2010-02-01  |  2KB  |  50 lines

  1. /* 
  2.     JSSTRINGS - LOADS LOCALIZED STRINGS USED BY JAVASCRIPT (BUNDLE)
  3.     Roberto bouzout (tito) <extensiondevelopment@gmail.com>
  4. */
  5.  
  6.     (function()
  7.     {
  8.         /*this function local variables*/
  9.             var debugingThisFile = false;//sets debuging on/off for this JavaScript file
  10.             var bundle; //reference to the metaTitleDescriptionOnTop-localization
  11.   /*shared*/var strings = [];//holds all the strings by the extension
  12.             
  13.         //it loads the bundle when the browser fully loaded
  14.             this.addListener('browserLoad', function (){metaTitleDescriptionOnTop.initJSStrings()});
  15.  
  16.         // init the bundle, called when the browser has been loaded 
  17.             this.initJSStrings = function()
  18.             {
  19.                 this.dump('initJSStrings', debugingThisFile);
  20.                 bundle = this.getElement('localization');
  21.                 strings = this.sharedObjectGet('jsStrings', strings);
  22.             };
  23.         //checks if 'aStringID' exists in memory if not exists is loaded, saved and returned
  24.             this.getString = function(aStringID)
  25.             {
  26.                 aStringID =  'metaTitleDescriptionOnTop.'+aStringID;
  27.                 this.dump('getString:aStringID:'+aStringID, debugingThisFile);
  28.                 if(!strings[aStringID])
  29.                 {
  30.                     try
  31.                     {
  32.                         strings[aStringID] = bundle.getString(aStringID);
  33.                     }
  34.                     catch(e)
  35.                     {
  36.                         //the default string is the ID it self, just to not break the test of the extension 
  37.                         strings[aStringID] = aStringID;
  38.                     }
  39.                     this.dump('getString:noExistsInMemory:aStringID:'+aStringID+':strings[aStringID]:'+strings[aStringID], debugingThisFile);
  40.                 }
  41.                 else
  42.                 {
  43.                     this.dump('getString:exists:aStringID:'+aStringID+':strings[aStringID]:'+strings[aStringID], debugingThisFile);
  44.                 }
  45.                 return strings[aStringID];
  46.             };
  47.             
  48.         return null;
  49.             
  50.     }).apply(metaTitleDescriptionOnTop);